using System.Diagnostics.Contracts;
using System.Linq;
using System.Collections.Generic;
using System;

namespace MishraReader.Entities.ShareServices
{
    [ContractClass(typeof(IShareServiceConfigurationViewModelContract))]
    public interface IShareServiceConfigurationViewModel
    {
        IServiceAccountViewModel ServiceAccountViewModel { get; set; }

        void Configure();

        void Disconnect();
    }

    [ContractClassFor(typeof(IShareServiceConfigurationViewModel))]
    internal abstract class IShareServiceConfigurationViewModelContract : IShareServiceConfigurationViewModel
    {
        public IServiceAccountViewModel ServiceAccountViewModel
        {
            get
            {
                Contract.Ensures(Contract.Result<IServiceAccountViewModel>() != null);
                return null;
            }
            set
            {
                Contract.Requires<ArgumentNullException>(value != null, "value");
            }
        }

        public void Configure()
        {
            Contract.Requires<InvalidOperationException>(ServiceAccountViewModel != null);
        }

        public abstract void Disconnect();
    }
}